package units.orbitals 
{
	import base.constants.Colors;
	import base.GShape;
	import interfaces.Generator;
	import appkit.responders.NResponder;
	import flash.events.Event;
	
	public class Asteroid extends Orbital implements Generator
	{
		private var limit:Vector.<uint>;
		private var gen:Vector.<uint>;
		
		
		/* generate resources */
		public function generate(rate:Vector.<uint>):Vector.<uint>
		{
			if (rate[0] <= limit[0])
			{
				gen[0] = rate[0];
				limit[0] -= rate[0];
			}
			else
			{
				gen[0] = limit[0];
				limit[0] = 0;
			}
			if (rate[1] <= limit[1])
			{
				gen[1] = rate[1];
				limit[1] -= rate[1];
			}
			else
			{
				gen[1] = limit[1];
				limit[1] = 0;
			}
			return gen;
				
		}
		
		/* set the limit for both resources for this generator */
		public function setLimit(l:Vector.<uint>):void
		{
			limit = l;
		}
		
		
		/* return the limit for both resources of this generator */
		public function getLimit():Vector.<uint>
		{
			return limit;
		}
		
		
		
		/* constructor */
		public function Asteroid(r:Number, dx:Number, dy:Number, l:Vector.<uint> = null)
		{
			var g:GShape = new GShape();
			g.draw(1, r, 2, Colors.Purple, .7, Colors.Black, .2);
			super(g)
			setLimit(l);
			gen = new Vector.<uint>();
			x = dx;
			y = dy;
			enable();
		}
		
	}

}